{extend name="common/base"/}

{block name="style"}
<style type="text/css">
  .clearfix {
    display: block;
  }

  .clearfix:after {
    content: ".";
    display: block;
    height: 0;
    clear: both;
    visibility: hidden;
  }

  * html .clearfix {
    height: 0.1%;
  }

  .panel-right {
    border-bottom: 1px solid #e8e8e8;
    padding: 0 20px 20px;
  }

  .panel-num table {
    width: 100%;
  }

  .panel-num td {
    text-align: center;
    padding: 20px 0;
    width: 16.6%;
    border-bottom: 1px solid #eee;
    border-left: 1px solid #eee
  }

  .panel-num .num-title {
    padding-bottom: 10px;
    color: #999;
  }

  .panel-num .num-num {
    font-size: 28px;
    font-weight: 300;
    color: #009688;
  }

  .latest-news {
    padding-top: 12px;
    padding-bottom: 30px;
    position: relative;
  }

  .latest-news .layui-timeline-title {
    padding-bottom: 0;
  }

  .latest-news .layui-timeline-item {
    padding-bottom: 1px;
  }

  .layui-timeline-title span {
    color: #999
  }

  .panel-more {
    width: 100%;
    height: 48px;
    line-height: 48px;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    background: linear-gradient(rgba(225, 225, 225, 0), rgba(225, 225, 225, .8));
  }

  .panel-more a {
    color: #0088FF
  }

  .index-row {
    margin-right: 351px;
  }

  .panel {
    padding: 0 20px;
    background-color: #fff;
  }

  .panel-title {
    font-size: 18px;
    font-weight: 800;
    padding: 20px 0 15px;
  }

  .table-title {
    font-size: 18px;
    font-weight: 800;
    padding: 20px 0 5px;
  }

  .row-right {
    width: 350px;
    float: right;
    border-left: 1px solid #e8e8e8;
    background-color: #f7f7f7;
  }
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<div style="background-color: #fff;">
  <div class="row-right">
    <div class="panel-right">
      <div class="table-title">最新动态</div>
      <div class="latest-news">
        <ul class="layui-timeline" id="logs">
        </ul>
        <div class="panel-more"><a href="/admin/api/log_list/">查看更多动态</a></div>
      </div>
    </div>
    <div class="panel-right">
      <div class="table-title">系统信息</div>
      <table class="layui-table" lay-skin="" lay-size="sm">
        {if condition="($install == true)"}
        <tr>
          <td colspan="2" style="color: #E94335;">提醒：发现app目录下的install文件夹没删除，为了系统的安全,请手动去删除。</td>
        </tr>
        {/if}
        <tr>
          <td><b>服务器系统</b></td>
          <td>{:get_system_info('os')}</td>
        </tr>
        <tr>
          <td><b>PHP版本</b></td>
          <td>{:get_system_info('php')}</td>
        </tr>
        <tr>
          <td><b>系统版本</b></td>
          <td>{:CMS_VERSION}</td>
        </tr>
        <tr>
          <td><b>ThinkPHP版本</b></td>
          <td>{:TP_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px"
              href="https://www.kancloud.cn/manual/thinkphp6_0" target="_blank">TP6文档</a></td>
        </tr>
        <tr>
          <td><b>Layui版本</b></td>
          <td>{:LAYUI_VERSION}<a class="layui-badge layui-bg-blue" style="margin-left:20px" href="https://www.layui.com/doc/"
              target="_blank">Layui文档</a></td>
        </tr>
        <tr>
          <td><b>上传附件限制</b></td>
          <td>{:get_system_info('upload_max_filesize')}</td>
        </tr>
        <tr>
          <td><b>执行时间限制</b></td>
          <td>{:get_system_info('max_execution_time')}</td>
        </tr>
        <tr>
          <td><b>BUG反馈</b></td>
          <td><a href="mailto:hdm58@qq.com" target="_blank">hdm58@qq.com</a></td>
        </tr>
      </table>
    </div>
  </div>


  <div class="index-row">
    <div class="panel-num">
      <table>
        <tr>
          <td>
            <div class="num-title">系统用户</div>
            <div class="num-num">{$adminCount}</div>
          </td>
          <td>
            <div class="num-title">注册用户</div>
            <div class="num-num">{$userCount}</div>
          </td>
          <td>
            <div class="num-title">文章</div>
            <div class="num-num">{$articleCount}</div>
          </td>
          <td>
            <div class="num-title">图片</div>
            <div class="num-num">0</div>
          </td>
          <td>
            <div class="num-title">产品</div>
            <div class="num-num">0</div>
          </td>
        </tr>
      </table>
    </div>
    <div class="panel">
      <div class="table-title">注册用户</div>
      <table id="UserList" lay-filter="UserList" class="layui-hide"></table>
      <div style="clear: left;"></div>
    </div>
    <div class="panel">
      <div class="table-title">文章列表</div>
      <table id="Article" lay-filter="Article" class="layui-hide"></table>
      <div style="clear: left;"></div>
    </div>
  </div>
  <div style="clear: right;"></div>
</div>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
  function getLogs() {
    $.ajax({
      url: "/admin/api/get_log_list",
      type: 'post',
      data: {
        page: 1,
        limit: 10
      },
      success: function (e) {
        if (e.code == 0) {
          var html = '';
          $.each(e.data, function (key, value) {
            html += '<li class="layui-timeline-item">\
										<i class="layui-icon layui-timeline-axis"></i>\
										<div class="layui-timeline-content layui-text">\
										  <div class="layui-timeline-title"><span title="'+value.id+'">'+ value.times + '</span>，' + value.content + '</div>\
										</div>\
									  </li>';
          });
          $('#logs').html(html);
        }
      }
    })
  }

  function init(layui) {
    var layer = layui.layer, table = layui.table;
    getLogs();
    //注册用户
    table.render({
      elem: '#UserList'
      , url: '/admin/api/get_user_list' //数据接口
      , page: false //开启分页
      , cols: [[ //表头
        { field: 'username', title: '用户名' }
        , {
          field: 'headimgurl', title: '头像', align: 'center', templet: function (d) {
            return '<img src="' + d.headimgurl + '" width="20" height="20" />';
          }
        }
        , { field: 'login_num', title: '登录次数', align: 'center' }
        , { field: 'last_login_time', title: '最后登录时间', align: 'center' }
      ]]
    });

    //文章
    table.render({
      elem: '#Article'
      , url: '/admin/api/get_article_list' //数据接口
      , page: false //开启分页
      , cols: [[ //表头
        { field: 'title', title: '标题' }
        , { field: 'cate_title', title: '分类', align: 'center' }
        , { field: 'create_time', title: '发布时间', align: 'center' }
      ]]
    });
  } 
</script>
{include file="common/layui" base='base' extend="[]" use="['table','layer']" callback="init" /}
{/block}
<!-- /脚本 -->